package com.example.zxx.springboot3.util;

import java.util.Objects;
import java.util.function.Consumer;

/**
 * ele
 */
public interface IThrowObjectUtil extends IThrowableUtil {

    IThrowObjectUtil BUILD = new IThrowObjectUtil() {
    };

    default <RE extends RuntimeException, T> void throwofIsNull(RE re, T object) {
        throwOf(Objects.isNull(object), re);
    }

    default <RE extends RuntimeException, T> void throwofIsNull(Consumer<RE> before, RE re, T object) {
        throwOf(before, Objects.isNull(object), re);
    }

    default <T> void throwofIsNull(String errMessage, T object) {
        throwofIsNull(new RuntimeException(errMessage), object);
    }

    default <T> void throwofIsNull(Consumer<RuntimeException> before, String errMessage, T object) {
        throwofIsNull(before, new RuntimeException(errMessage), object);
    }

    default <RE extends RuntimeException, T> void throwofNonNull(RE re, T object) {
        throwOf(Objects.nonNull(object), re);
    }

    default <RE extends RuntimeException, T> void throwofNonNull(Consumer<RE> before, RE re, T object) {
        throwOf(before, Objects.nonNull(object), re);
    }

    default <T> void throwofNonNull(String errMessage, T object) {
        throwofNonNull(new RuntimeException(errMessage), object);
    }

    default <T> void throwofNonNull(Consumer<RuntimeException> before, String errMessage, T object) {
        throwofNonNull(before, new RuntimeException(errMessage), object);
    }

    default <T> void throwofEquals(String errMessage, T object, T competitor) {
        throwofEquals(new RuntimeException(errMessage), object, competitor);
    }

    default <T> void throwofEquals(Consumer<RuntimeException> before, String errMessage, T object, T competitor) {
        throwofEquals(before, new RuntimeException(errMessage), object, competitor);
    }

    default <T> void throwofNotEquals(String errMessage, T object, T competitor) {
        throwofNotEquals(new RuntimeException(errMessage), object, competitor);
    }

    default <T> void throwofNotEquals(Consumer<RuntimeException> before, String errMessage, T object, T competitor) {
        throwofNotEquals(before, new RuntimeException(errMessage), object, competitor);
    }

    default <RE extends RuntimeException, T> void throwofEquals(RE re, T object, T competitor) {
        throwOf(Objects.equals(object, competitor), re);
    }

    default <RE extends RuntimeException, T> void throwofEquals(Consumer<RE> before, RE re, T object, T competitor) {
        throwOf(before, Objects.equals(object, competitor), re);
    }

    default <RE extends RuntimeException, T> void throwofNotEquals(RE re, T object, T competitor) {
        throwOf(!Objects.equals(object, competitor), re);
    }

    default <RE extends RuntimeException, T> void throwofNotEquals(Consumer<RE> before, RE re, T object, T competitor) {
        throwOf(before, !Objects.equals(object, competitor), re);
    }
}